//Console.cpp
//Roger65
//http://www.codeguru.com/Cpp/W-D/console/article.php/c3959/

#include <windows.h>
#include "..\VERS_DECL.h"
#include "CC.h"

void setrgb(int color)
{
	switch(color)
	{
		case 0:    // White on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_RED |
				FOREGROUND_GREEN | FOREGROUND_BLUE);
			break;
		case 1:    // Red on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_RED);
			break;
		case 2:    // Green on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_GREEN);
			break;
		case 3:    // Yellow on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_RED |
				FOREGROUND_GREEN);
			break;
		case 4:    // Blue on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_BLUE);
			break;
		case 5:    // Magenta on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_RED |
				FOREGROUND_BLUE);
			break;
		case 6:    // Cyan on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				FOREGROUND_INTENSITY | FOREGROUND_GREEN |
				FOREGROUND_BLUE);
			break;
		case 7:    // Black on Gray
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | BACKGROUND_INTENSITY);
			break;
		case 8:    // Black on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE);
			break;
		case 9:    // Red on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_RED);
			break;
		case 10:    // Green on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_GREEN);
			break;
		case 11:    // Yellow on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_RED |
				FOREGROUND_GREEN);
			break;
		case 12:    // Blue on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_BLUE);
			break;
		case 13:    // Magenta on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_RED |
				FOREGROUND_BLUE);
			break;
		case 14:    // Cyan on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
				BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
				BACKGROUND_RED | BACKGROUND_GREEN |
				BACKGROUND_BLUE | FOREGROUND_GREEN |
				FOREGROUND_BLUE);
			break;
		case 15:    // White on White
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
                BACKGROUND_INTENSITY | FOREGROUND_INTENSITY |
                BACKGROUND_RED | BACKGROUND_GREEN |
                BACKGROUND_BLUE | FOREGROUND_RED |
                FOREGROUND_GREEN | FOREGROUND_BLUE);
			break;
		default :    // White on Black
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
                FOREGROUND_INTENSITY | FOREGROUND_RED |
				FOREGROUND_GREEN | FOREGROUND_BLUE);
			break;
	}
}

string get_vers(bool _full, string divider, string _vers)
{
	size_t first, second, third, fourth, fifth;
	string S_a, S_b, S_c, S_d; //String parts

	first = _vers.find('\"');
	second = _vers.find(',', (first + 1));
	third = _vers.find(',', (second + 1));
	fourth = _vers.find(',', (third + 1));
	fifth = _vers.find('\"', (fourth + 1));

	S_a = _vers.substr((first + 1), (second - first - 1));
	S_b = _vers.substr((second + 1), (third - second - 1));
	S_c = _vers.substr((third + 1), (fourth - third - 1));
	S_d = _vers.substr((fourth + 1), (fifth - fourth - 1));
	if(_full)
	{
		return (S_a + divider + S_b + divider + S_c + divider + S_d);
	}
	else
	{
		return S_c;
	}
}